Skip to content

fix(mcp): a child's async question no longer keeps its parent polling - #40604

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
navidnadali:up/thread-wait-hint
Nov 21, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
navidnadali:up/thread-wait-hint

Conversation

@navidnadali

Copy link
Copy Markdown
Contributor

Note

Written by Claude Opus 5.5 on behalf of Navid

Problem

When t3_thread_wait times out on a running run of the caller's own delegated task, it adds next ("Completion wakes
this thread. ... end your turn when none is left."). It leaves next out while the child thread has any pending
runtime request. task_status leaves it out only for a live question or approval (hasPendingQuestion and
pendingTaskApproval check responseCapability.type === "live"), and #24782 meant the wait to apply that same rule.

A Codex async question (request_user_input_async, #9512) is a pending user_input request with
responseCapability: { type: "message" }: Codex keeps working, the answer arrives as a later message, and the
question stays pending after the turn ends. So for the same running child task_status returns next and
t3_thread_wait does not. The tool says "On timeout, with next end your turn; without, call again", so the parent
keeps calling it until the child finishes.

On main (the wait finds the task through the run's delegatedTaskId, which a follow-up task's run carries):

  1. A parent delegates a Codex task and, once it has finished, sends it more work with t3_thread_send, which starts
    a follow-up task on the child thread.
  2. The child calls request_user_input_async and keeps working. CodexAdapterV2 records a pending request answered
    by message, and DelegatedTaskQuestionReactor tells the parent the task "asked a question and is still working".
  3. The parent's t3_thread_wait on the child times out without next, while task_status for the follow-up task
    returns it.

An async question left unanswered by an earlier run does the same: a completed run does not dismiss it, so the wait
on every later follow-up goes without next until someone answers or dismisses that question.

Change

t3_thread_wait withholds next only for a pending live request, as task_status does. A live question or approval
still withholds it.

Scope

A small fix for an obvious bug (two tools disagree about the same running child), so no issue. #24712 (open) changes
the same function to return early on live input; it keeps this check, so the bug remains with it.

Verification

vp test run src/mcp/OrchestratorMcpService.test.ts -t "tells the parent to end its turn only while its task still runs" from apps/server. The case's pending request now has a kind and a response capability: a live one still gets
no next, and a new row with a question answered by message expects next. On main it fails by assertion
(expected undefined to equal 'Completion wakes this thread. ...'); with the change the file passes (97 tests).

Runtime transcript: the real orchestrator, projection store (in-memory SQLite), ThreadManagementService and
OrchestratorMcpService, with a scripted provider that emits CodexAdapterV2's async-question events. A parent
delegates a task, the task finishes, and the parent sends follow-ups. At each step it calls task_status and
t3_thread_wait (which times out) on the child:

Child state Pending requests task_status gives next (main / PR) t3_thread_wait gives next (main / PR)
Follow-up working, no question none yes / yes yes / yes
Asks an async question, keeps working message yes / yes no / yes
Also blocked on a live question message, live no / no no / no
Next follow-up working, the async question still open message yes / yes no / yes

macOS arm64, Node 26.13.1; the same on Linux x86_64 and Linux arm64 (Debian 13, Node 26.13.1).
To reproduce from checkouts of main and this PR with dependencies installed, run
bash run.sh main=<main checkout> fix=<PR checkout> from https://gist.github.com/navidnadali/0ab53dfeed268cc6f09f82ac81d2ae8e (it copies the transcript test into each
checkout, runs it and removes it).

Also: vp run check:changed passes, and vp test run integration from apps/server passes (417 tests). The changed
case passed 20 of 20 runs, four at a time, on macOS, Linux arm64 and Linux x86_64.

Not checked: a live Codex run. The transcript's provider sends the shape CodexAdapterV2 emits for an async question,
which main's adapter test keeps an asynchronous Codex question actionable after the turn completes covers.

Made with Claude Opus 5.5 via Claude Code. Reviewed by GPT-6.1 Sol via Codex.

🤖 Generated with Claude Code

A Codex child can ask a question that a later message answers and keep
working. task_status already gives such a running task its "end your
turn" hint, but t3_thread_wait withheld it for any pending request, so
the parent was told to call again for as long as the child worked. Only a
live question or approval holds the hint back now, as in task_status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

waitForThread now suppresses the caller’s continuation hint only when a pending child runtime request has a live response capability. Tests cover pending live and message response requests.

Changes: Caller Wake

Layer / File(s) Summary
Caller-wake condition and tests
apps/server/src/mcp/OrchestratorMcpService.ts, apps/server/src/mcp/OrchestratorMcpService.test.ts
waitForThread ignores pending requests without a live response capability when deciding whether to wake the caller. Tests verify that live requests suppress the next hint and message requests retain it.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, shivamhwp

Merge Risk: Minimal · up to 28b49

This change makes t3_thread_wait withhold its next hint only while a child has a pending live question or approval. A parent whose child has an async question answered by a later message can now end its turn instead of polling. No concrete defect was found, so the merge-readiness risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a child's async question no longer keeps its parent polling. The raw summary shows the wait logic in OrchestratorMcpService.ts now withholds the next hint only for a p…
Description check Passed The description follows the repository template's sections: Problem, Change, Scope, and Verification. It explains the bug with a clear reproduction path, names the one-line change, and gives a scope r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a child's async question no longer keeps its parent polling. The raw summary shows the wait logic in OrchestratorMcpService.ts now withholds the next hint only for a pending request with a live response capability. The title is specific, follows conventional commit form, and matches the objectives. It is a clear fit.

Full details: Description check

Explanation

The description follows the repository template's sections: Problem, Change, Scope, and Verification. It explains the bug with a clear reproduction path, names the one-line change, and gives a scope rationale that links the related open PR. Verification lists the focused test command, the before and after results, integration test counts, and what was not checked. The template's reminder about a model attribution line is also addressed. Minor gap: the template asks for an issue link or a reason for none, and the author gives a reason (small obvious bug), which satisfies it.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7b6e747 and 28b4901.

Files selected for processing: 1

  • apps/server/src/mcp/OrchestratorMcpService.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 21, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Ran the same sequence in the real web app on both commits: delegate → READY → follow-up asking an async Red/Blue question and running sleep 150 → t3_thread_wait(timeoutMs: 20000) → task_status. The child remained active with one pending message-answered question. Base timed out without next; head timed out with the completion-wake hint. task_status supplied the hint on both.

Environment: Linux Chromium, dark theme, 1440×1000 CSS viewport, DPR 2; separate fresh databases, synthetic projects, real Codex gpt-6.1-sol parent/child turns. Images show cropped response fields from the app; videos show the interaction and unanswered question.

Before After
b5709bb865 28b490171f
Before: wait omits next After: wait includes next
Before recording After recording
Full base runtime responses Full head runtime responses

Exact prompt, launch driver, runtime capture script, supplemental runtime and stability evidence.

Not shown:

  • Pending blocking live questions and approvals were not exercised as control cases.
  • The optional second follow-up while the first async question remains open was not exercised.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 21, 2026
@juliusmarminge
juliusmarminge merged commit 63fa4c8 into pingdotgg:main Nov 21, 2026
59 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants